#include "../include/Competence.h"
#include <string.h>
/*
Competence::Competence ()
{

}
*/
Competence::Competence(std::string p_nom, int p_cout_mana, int p_cout_action, int p_mult_force, int p_plus_force, int p_mult_myst, int p_plus_myst,
                   int p_mult_end_adv, int p_plus_end_adv, int p_mult_myst_adv, int p_plus_myst_adv)
{
    nom = p_nom;
    cout_mana = p_cout_mana;
    cout_point_action = p_cout_action;
    mult_force = p_mult_force;
    plus_force = p_plus_force;
    mult_myst = p_mult_myst;
    plus_myst = p_plus_myst;
    mult_end_adv = p_mult_end_adv;
    plus_end_adv = p_plus_end_adv;
    mult_myst_adv = p_mult_myst_adv;
    plus_myst_adv = p_plus_myst_adv;
}

Competence::~Competence()
{
    //dtor
}

std::string Competence::recup_nom ()
{
    return nom;
}

int Competence::recup_cout_mana ()
{
    return cout_mana;
}

int Competence::recup_cout_point_action ()
{
    return cout_point_action;
}

int Competence::recup_mult_force ()
{
    return mult_force;
}

int Competence::recup_plus_force ()
{
    return plus_force;
}

int Competence::recup_mult_myst ()
{
    return mult_myst;
}

int Competence::recup_plus_myst ()
{
    return plus_myst;
}

int Competence::recup_mult_end_adv ()
{
    return mult_end_adv;
}

int Competence::recup_plus_end_adv ()
{
    return plus_end_adv;
}

int Competence::recup_mult_myst_adv ()
{
    return mult_myst_adv;
}

int Competence::recup_plus_myst_adv ()
{
    return plus_myst_adv;
}

int Competence::degats_physique (Creature* p_creature_att, Arme* p_arme, Creature*  p_creature_def,
                                  Armure* p_armure)
{
    int degats;
    degats = this->mult_force*p_creature_att->recup_force()+this->plus_force+p_arme->recup_alteration_force()-
        this->mult_end_adv*p_creature_def->recup_endurance()-this->plus_end_adv-p_armure->recup_alteration_endurance();
    return degats;
}

int Competence::degats_magique ( Creature* p_creature_att, Arme* p_arme, Creature* p_creature_def, Armure* p_armure)
{
    int degats;
    degats = this->mult_myst*p_creature_att->recup_mysticisme() + this->plus_myst + p_arme->recup_alteration_mysticisme()
        - this->mult_myst_adv*p_creature_def->recup_mysticisme() - this->plus_myst_adv-p_armure->recup_alteration_mysticisme()
        - this->mult_end_adv*p_creature_def->recup_endurance() - this->plus_end_adv-p_armure->recup_alteration_endurance();
    return degats;
}

int Competence::degats_perce_armure ( Creature* p_creature_att, Arme* p_arme, Creature* p_creature_def)
{
    int degats;
    degats = this->mult_force*p_creature_att->recup_force()+this->plus_force+p_arme->recup_alteration_force()-
        this->mult_end_adv*p_creature_def->recup_endurance()-this->plus_end_adv;
    return degats;
}

int Competence::degats_soin ( Creature* p_creature_att, Arme* p_arme)
{
    int degats;
    degats = this->mult_myst*p_creature_att->recup_mysticisme()+this->plus_myst+p_arme->recup_alteration_mysticisme();
    degats = -degats;
    return degats;
}

int Competence::degats ( Creature* p_creature_att, Creature* p_creature_def)
{
    int degats;

    if (this->nom == "Attaque" || this->nom == "Attaque rapide" || this->nom == "Coup puissant")
    {
        degats = this->degats_physique (p_creature_att, p_creature_att->recup_arme_equipe(), p_creature_def, p_creature_def->recup_armure_equipe());
    }
    else if (this->nom == "Magie" || this->nom == "Boule de feu")
    {
        degats = this->degats_magique (p_creature_att, p_creature_att->recup_arme_equipe(), p_creature_def, p_creature_def->recup_armure_equipe());
    }
    else if (this->nom == "Perce armure")
    {
        degats = this->degats_perce_armure (p_creature_att, p_creature_att->recup_arme_equipe(), p_creature_def);
    }
    else if (this->nom == "Soin")
    {
        degats = this->degats_soin (p_creature_att, p_creature_att->recup_arme_equipe());
    }
    else
    {
        degats = -2147483648;
    }

    /*
    switch (this->nom)
    {
        case "attaque" :
        case "attaque rapide" :
                                degats = this->degats_physique (p_creature_att, p_arme, p_creature_def, p_armure);
                                break;
        case "magie" :
        case "boule de feu" :
                                degats = this->degats_magique (p_creature_att, p_arme, p_armure);
                                break;
        case "perce armure" :   degats = this->degats_perce_armure (p_creature_att, p_arme);
                                break;
        case "soin" :           degats = this->degats_soin (p_creature_att, p_arme);
                                break;
    }
    */

    return degats;

}
